package ui;

import javax.swing.JWindow;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.Toolkit;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.ImageIcon;

import text.ChineseStem;

public class LoadingWindows extends JWindow
{
    private Main           main         = null;
    private JPanel         jContentPane = null;
    private JLabel         jLabel       = null;
    private JLabel         jLabel1      = null;
    private LoadingWindows self         = null;

    /**
     * This method initializes
     * 
     */
    public LoadingWindows(Main su)
    {
        super(su);
        this.main = su;
        self = this;
        main.getThreadLock().lock();
        initialize();
        Timer t = new Timer();
        t.schedule(new TimerTask()
        {
            public void run()
            {
                jLabel.setText("读取数据库...");
                main.getQuerier();
                jLabel.setText("读取链接信息...");
                main.getUrlMap();
                jLabel.setText("读取分词器...");
                new ChineseStem();
                main.getThreadLock().unlock();
                self.dispose();
            }
        }, 1000);
    }

    /**
     * This method initializes this
     * 
     */
    private void initialize()
    {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screenSize.width - 163) / 2;
        int y = (screenSize.height - 83) / 2;
        this.setLocation(x, y);
        this.setSize(new Dimension(163, 83));
        this.setContentPane(getJContentPane());
        this.setVisible(true);
    }

    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane()
    {
        if (jContentPane == null)
        {
            jLabel1 = new JLabel();
            jLabel1.setBounds(new Rectangle(15, 44, 138, 29));
            jLabel1.setIcon(new ImageIcon(getClass().getResource(
                    "/img/loader.gif")));
            jLabel1.setText("");
            jLabel = new JLabel();
            jLabel.setBounds(new Rectangle(15, 16, 137, 20));
            jLabel.setFont(new Font("\u65b0\u5b8b\u4f53", Font.PLAIN, 14));
            jLabel.setText("初始化信息");
            jContentPane = new JPanel();
            jContentPane.setLayout(null);
            jContentPane.add(jLabel, null);
            jContentPane.add(jLabel1, null);
        }
        return jContentPane;
    }

} // @jve:decl-index=0:visual-constraint="9,9"
